import java.util.Arrays;

public class BinarySearch {
    public static void main(String[] args) {
        int[] arr = {1,3,5,7,9,11};
        int target = 3;
        System.out.println(search(arr, target));
    }
    public static int search(int[] arr, int target){
        int left = 0;
        int right = arr.length - 1;
        while (left <= right){
            int mid = (left + right) >>> 1;
            if (arr[mid] < target){
                left = mid + 1;
            } else if (target < arr[mid]) {
                right = mid - 1;
            }else {
                return mid;
            }
        }
        return -1;
    }
}
